package com.das.mechanic_base.mvp.presenter.create;

import com.das.mechanic_base.base.X3BasePresenter;
import com.das.mechanic_base.bean.create.SelectWorkBean;
import com.das.mechanic_base.bean.main.DoneDetectionBean;
import com.das.mechanic_base.mapi.api.NetWorkHttp;
import com.das.mechanic_base.mapi.response.HttpCallBack;
import com.das.mechanic_base.mapi.schedulers.RxSchedulersHelper;
import com.das.mechanic_base.mvp.contract.create.X3SelectWorkContract;

import java.util.List;
import java.util.Map;

public class X3SelectWorkPresenter extends X3BasePresenter<X3SelectWorkContract.View> implements X3SelectWorkContract.Presenter{

    @Override
    public void getServiceList(Map<String, Object> map) {

        NetWorkHttp.getApi().getServiceBaseListInfoForWork(map)
                .compose(RxSchedulersHelper.defaultComposeRequest())
                .compose(mView.bindToLife())
                .subscribe(new HttpCallBack<List<SelectWorkBean>>() {
                    @Override
                    protected void onDone(List<SelectWorkBean> selectWorkBeans) {
                        mView.getServiceListSuccess(selectWorkBeans, (String) map.get("keyWord"));
                    }

                    @Override
                    protected void showError(String error) {
                        mView.getServiceListFail();
                    }
                });

    }

    @Override
    public void getDoneDetectionList(long receiveBaseId) {
        NetWorkHttp.getApi().getDoneDetectionList(receiveBaseId)
                .compose(RxSchedulersHelper.defaultComposeRequest())
                .subscribe(new HttpCallBack<List<DoneDetectionBean>>() {
                    @Override
                    protected void onDone(List<DoneDetectionBean> mList) {
                        mView.getDoneDetectionListSuccess(mList);
                    }

                    @Override
                    protected String LoadingMessage() {
                        return null;
                    }

                    @Override
                    protected void showError(String error) {

                    }
                });
    }
}
